using System;
using UnityEngine;
using UnityEngine.UI;

public class GooglePlayDialog : MonoBehaviour
{
	public GameObject gpgObject;

	public GameObject block;

	public RectTransform gpgDialog;

	public Image fade;

	private void Start()
	{
		gpgDialog.localScale = new Vector2(0f, 0f);
		if (!PlayerPrefs.HasKey("GPG"))
		{
			OpenDialog();
			return;
		}
		if (PlayerPrefs.GetInt("GPG") == 1)
		{
			EnableGooglePlay();
			return;
		}
		UnityEngine.Object.Destroy(base.gameObject);
		UnityEngine.Object.Destroy(block);
	}

	public void EnableGooglePlay()
	{
		UnityEngine.Object.FindObjectOfType<GooglePlayInitializer>().ActivateGooglePlay();
		CloseDialog();
	}

	public void DisableGooglePlay()
	{
		PlayerPrefs.SetInt("GPG", 0);
		CloseDialog();
	}

	public void OpenDialog()
	{
		gpgObject.SetActive(value: true);
		block.SetActive(value: true);
		LeanTween.scale(gpgDialog, new Vector3(1f, 1f), 0.2f).setEase(LeanTweenType.easeOutSine);
	}

	public void CloseDialog()
	{
		LeanTween.scale(gpgDialog, new Vector3(0f, 0f), 0.2f).setEase(LeanTweenType.easeOutSine).setOnComplete((Action<object>)delegate
		{
			gpgObject.SetActive(value: false);
		});
		fade.CrossFadeAlpha(0f, 0.2f, ignoreTimeScale: true);
		block.SetActive(value: false);
	}
}
